package com.example.barcodeapp.ui.wode.activity;

import android.os.Bundle;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.barcodeapp.R;
import com.example.barcodeapp.base.BaseActivity;
import com.example.barcodeapp.base.BaseAdapter;
import com.example.barcodeapp.interfaces.own.IOwn;
import com.example.barcodeapp.persenter.OnePresenterJiFengBiChongZhi;
import com.example.barcodeapp.ui.wode.adapter.ChongZhiAdapter;
import com.example.barcodeapp.ui.wode.bean.JifengBiChongZhiJinEBean;
import com.example.barcodeapp.ui.wode.bean.JifengbichongzhishuomingBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class JiFengBiChongZhiActivity extends BaseActivity<IOwn.Persenterjifengbichongzhi> implements IOwn.Viewjifengbichongzhi {
    @BindView(R.id.iv_back_circle)
    ImageView ivBackCircle;
    @BindView(R.id.ff_back_contener)
    FrameLayout ffBackContener;
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.tv_location)
    TextView tvLocation;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.ll_to_search)
    LinearLayout llToSearch;
    @BindView(R.id.right_iv)
    ImageView rightIv;
    @BindView(R.id.right_iv_two)
    ImageView rightIvTwo;
    @BindView(R.id.tv_rught_)
    TextView tvRught;
    @BindView(R.id.tv_right_two)
    TextView tvRightTwo;
    @BindView(R.id.toolBar)
    Toolbar toolBar;
    @BindView(R.id.rel_head_biaoti)
    LinearLayout relHeadBiaoti;
    @BindView(R.id.tv_jifengbiyue)
    TextView tvJifengbiyue;
    @BindView(R.id.tv_yue)
    TextView tvYue;
    @BindView(R.id.tv_select)
    TextView tvSelect;
    @BindView(R.id.rec_chongzhi)
    RecyclerView recChongzhi;
    @BindView(R.id.tv_chongzhishuoming)
    TextView tvChongzhishuoming;
    @BindView(R.id.tv_shuoming)
    TextView tvShuoming;
    @BindView(R.id.tv_zhifu)
    TextView tvZhifu;

    @Override
    protected int getLayout() {
        return R.layout.jifengbichonghzi_acyivity;
    }

    @Override
    protected void initView() {
        setToolBar(true, false, true, false, false);
        setTitle("充值", R.color.black, R.color.white);
    }

    @Override
    protected OnePresenterJiFengBiChongZhi initPersenter() {
        return new OnePresenterJiFengBiChongZhi();
    }

    @Override
    protected void initData() {
    persenter.getjifengbichoznghi();
    persenter.getjifengbichoznghishuoming();
    }

    @Override
    public void getjifengbichongzhi(JifengBiChongZhiJinEBean xiLieKeBean) {
        List<JifengBiChongZhiJinEBean.DataEntity> data = xiLieKeBean.getData();
        for (int i = 0; i < data.size(); i++) {

            if (i==0){
                data.get(i).setSelect(true);
            }else {
                data.get(i).setSelect(false);
            }
        }
        recChongzhi.setLayoutManager(new GridLayoutManager(this, 3));
        ChongZhiAdapter chongZhiAdapter = new ChongZhiAdapter(this, data);
        recChongzhi.setAdapter(chongZhiAdapter);
        chongZhiAdapter.notifyDataSetChanged();
        chongZhiAdapter.setClick(new BaseAdapter.IClick() {
            @Override
            public void click(int pos) {
                for (int i = 0; i < data.size(); i++) {
                    data.get(i).setSelect(false);
                }
                data.get(pos).setSelect(true);
                chongZhiAdapter.notifyDataSetChanged();
            }
        });
    }

    @Override
    public void getjifengbichoznghishuoming(JifengbichongzhishuomingBean xiLieKeBean) {
        tvShuoming.setText(xiLieKeBean.getData().getText());
    }

}
